home *** CD-ROM | disk | FTP | other *** search
- Path: news1.is.net!news
- From: Mark VanTassel <mvantassel@teambca.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Operator overloading
- Date: Tue, 12 Mar 1996 08:02:17 -0500
- Organization: Barfield, Cauthen and Associates
- Message-ID: <314575D9.3A2A@teambca.com>
- References: <313F19B5.41C6@lfa.uni-wuppertal.de>
- NNTP-Posting-Host: dynamic12.is.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- > const T& operator[](unsigned long int index) const;
- >
- > I know, it is an subscription overloading, for something like
- > v[i], where i is of type unsigned long int and v of type T.
- >
- > What's the meaning of the const at the end
- > and the beginning of the line ?
- >
-
- The const at the end says that this member function (it must be a member, since it only defines
- one argument) cannot modify the state of the object to which it is being applied (the
- pseudo-array which is being "indexed").
-
- The const at the beginning says that the object (of type T) to which a reference is returned
- cannot be modified by the caller of this "index" operation.
-
- (Note that both can be overridden by casting the constness away. This should NEVER be done,
- except in certain circumstances ;-)
-